package com.topInterview;

/**
 * @Author: huangzhigao
 * @Date: 2022/2/26 10:42
 */
public class leecode387_FirstUniqueChar {
    public int firstUniqChar(String s) {
        int[] ints = new int[256];
        char[] chars = s.toCharArray();
        for (char c : chars) {
            ints[c - 'a']++;
        }

        for (int i = 0; i < chars.length; i++) {
            if (ints[chars[i] - 'a'] == 1) {
                return i;
            }
        }
        return -1;
    }
}
